package cn.jlearn.proxy.web.service.impl;

import cn.jlearn.proxy.web.mapper.DownAgentMapper;
import cn.jlearn.proxy.web.model.DownAgent;
import cn.jlearn.proxy.web.service.HomeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author qianyingchao
 * @version 1.0
 * @date 2021/7/21 2:58 下午
 */
@Service
public class HomeServiceImpl implements HomeService {

    @Resource
    private DownAgentMapper downAgentMapper;

    @Override
    public DownAgent getLatestAgent() {
        LambdaQueryWrapper<DownAgent> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByDesc(DownAgent::getId);
        queryWrapper.last("limit 0,1");
        return downAgentMapper.selectOne(queryWrapper);
    }

}
